class CartController < ApplicationController
  skip_before_filter :require_login

  def index
    cart = get_cart

    if cart.line_items != nil
      @cart_show = cart
      @aaa = '12321'
    end
  end

  def remove
  end

  def add
    product_id = params[:product_id]
    if product_id != nil
      product = Product.find(product_id)
      cart = get_cart
      exist = false
      cart.line_items.each do |line_item|
        if line_item.product.id == product.id
          line_item.amount += 1
          exist = true
          @zzz = '123'
        end
      end
      if !exist
        cart.line_items.push(LineItem.new)
        cart.line_items.last.product = Product.find(product_id)
        cart.line_items.last.amount = 1
        @xxx = '456'
      end
    end
  end

  def order
  end
end
